package com.pro.servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.pro.dao.impl.ProductDaoImpl;
import com.pro.dao.impl.ProductImgDaoImpl;
import com.pro.dao.impl.ProductTypeDaoImpl;
import com.pro.entity.ProductEntity;
import com.pro.util.BaseServlet;

/**
 * Servlet implementation class ProductServlet
 */
public class ProductServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
       
ProductDaoImpl pDaoImpl= new ProductDaoImpl();
ProductTypeDaoImpl pTypeDaoImpl= new ProductTypeDaoImpl();
ProductImgDaoImpl pImgDaoImpl = new ProductImgDaoImpl();

	
	public void productAll(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		int pid=Integer.parseInt(request.getParameter("pid"));
		       //产品案例
		request.setAttribute("pList", pDaoImpl.productAll(pid));
		request.setAttribute("productTypeList", pTypeDaoImpl.productType());
		request.setAttribute("selectTypeId", pid);
		
		request.getRequestDispatcher("productlist.jsp").forward(request, response);
	}
			
	public void productDetail(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		int gid=Integer.parseInt(request.getParameter("gid"));
		int pid=Integer.parseInt(request.getParameter("pid"));
		//产品案例
		request.setAttribute("productImg", pImgDaoImpl.productImg());
		request.setAttribute("product", pDaoImpl.productDetail(gid));
		request.setAttribute("productTypeList", pTypeDaoImpl.productType());
		request.setAttribute("selectTypeId", pid);
		
		request.getRequestDispatcher("productdetails.jsp").forward(request, response);
	}

}
